


#include <stdio.h>
#include "Nano1X2Series.h"

#include "rt5621.h"
#include "GPIO_IIC.h"




#define RT5621_SLAVE_ADDR	0X34

void RT5621_init()
{
	uint16_t readbk;
	
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD1,0x8030);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD2,0x2730);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD3,0x8600);

	
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_AUXIN_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_LINE_IN_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_DAC_VOL,0x0808);

	
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_DAC_VOL,0x6808);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_OUTPUT_MIXER_CTRL,0xc300);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_HP_OUT_VOL,0x1212);

//	
	
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_AUDIO_INTERFACE,0x80c0);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_AD_DA_CLK_CTRL,0x066d);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GLOBAL_CLK_CTRL_REG,0x8000);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PLL_CTRL,0x0040);

//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_DAC_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADC_REC_MIXER,0x3f3f);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_CTRL,0x0a00);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_SPK_OUT_VOL,0x8080);
//	
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADD_CTRL_REG,0x4b00);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_AD_DA_CLK_CTRL,0x0a2d);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADC_REC_GAIN,0xfa95);
//	write_reg_8(RT5621_SLAVE_ADDR,RT5621_HID_CTRL_INDEX,0x0c);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_ROUTING_CTRL,0xf0e0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_HID_CTRL_DATA,0xfec);
	write_reg_16(RT5621_SLAVE_ADDR,RT5621_JACK_DET_CTRL,0x0110);



	//write_reg_16(RT5621_SLAVE_ADDR,RT5621_RESET,0x59b4);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_SPK_OUT_VOL,0x0000);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_HP_OUT_VOL,0x0909);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MONO_AUX_OUT_VOL,0x0000);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_AUXIN_VOL,0xe808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_LINE_IN_VOL,0x6808);
//	
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_DAC_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_VOL,0x0808);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_ROUTING_CTRL,0xf0e0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADC_REC_GAIN,0xfa95);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADC_REC_MIXER,0x3f3f);
//	
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_SOFT_VOL_CTRL_TIME,0x0009);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_OUTPUT_MIXER_CTRL,0x2b40);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MIC_CTRL,0x0a00);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_AUDIO_INTERFACE,0x8000);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_STEREO_AD_DA_CLK_CTRL,0x0a2d);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_COMPANDING_CTRL,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD1,0x8030);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD2,0xe738);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD3,0x9600);

//	
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_ADD_CTRL_REG,0x4b00);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GLOBAL_CLK_CTRL_REG,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PLL_CTRL,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_OUTPUT_PIN_CTRL,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_CONFIG,0x1c0e);

//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_POLARITY,0x1c0e);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_SHARING,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_STICKY,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_WAKEUP,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_GPIO_PIN_STATUS,0x0002);


//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_JACK_DET_CTRL,0x0110);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_MISC_CTRL,0x0);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PSEDUEO_SPATIAL_CTRL,0x0497);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_EQ_CTRL,0x8003);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_EQ_MODE_ENABLE,0x0);

//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_AVC_CTRL,0x000b);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_HID_CTRL_DATA,0x0fec);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_HID_CTRL_INDEX,0x000c);
//	

//	readbk=read_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD1);
//	write_reg_16(RT5621_SLAVE_ADDR,RT5621_PWR_MANAG_ADD1,readbk);

}

